package com.dsteiner.xelavos.client.domain;

import java.util.Date;

import javax.jdo.annotations.Embedded;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.dsteiner.widgets.client.ObjectUtil;
import com.dsteiner.widgets.client.domain.ModelObject;
import com.dsteiner.widgets.client.domain.Searchable;
import com.dsteiner.widgets.client.domain.SearchableId;
import com.dsteiner.widgets.client.domain.SearchableProperty;
import com.dsteiner.widgets.client.domain.SearchableRefId;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
@Searchable
public class Rating extends ModelObject{

	public Rating() {
	}
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    @SearchableId
    private String id;
	
	public String getId(){
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}

    @Persistent
    @SearchableRefId
	private String userId;
	
    @Persistent
    @SearchableProperty
	private int rating;
	
    @Persistent
    @SearchableRefId
	private String refId;
    
    @Persistent
	private String refClass;

    @Persistent
    @SearchableProperty
    private Date registeredDate;

    public Date getRegisteredDate() {
		return registeredDate;
	}
    public void setRegisteredDate(Date registeredDate) {
		this.registeredDate = registeredDate;
	}
    
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public int getRating() {
		return rating;
	}
	public void setRating(int rating) {
		this.rating = rating;
	}

	public String getRefClass() {
		return refClass;
	}
	public String getRefId() {
		return refId;
	}
	public void setRefClass(String refClass) {
		this.refClass = refClass;
	}
	public void setRefId(String refId) {
		this.refId = refId;
	}
    public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (!(obj instanceof Rating))
			return false;
		Rating other = (Rating) obj;
		return ObjectUtil.equals(id, other.id);
	}
}
